class UserInfo {
  checkUser() {
    return new Promise((resolve, reject) => {
      console.log('page',wx.getStorageSync('user') )
      if(!wx.getStorageSync('user')) {
        wx.getSetting({
          success(res) {
            if (!res.authSetting['scope.userInfo']) {
              resolve(false)
            } else {
              wx.getUserInfo({
                success: res => {
                  wx.setStorageSync('user', res.userInfo)
                  resolve(res.userInfo)
                }
              })
            }
          }
        })
      } else {
        resolve(wx.getStorageSync('user'))
      }
    })
  }
}

export {
  UserInfo
}